package com.pf.utils;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pf.dto.PageBaseResp;
import org.springframework.beans.BeanUtils;

/**
 * @author PanFei
 * @version 1.0.0
 * @createTime 2021/8/27
 */
public class PageUtils {

    /**
     * 将mybatis-plus的IPage类型转为PageBaseResp类型
     *
     * @param page
     * @param <T>
     * @return
     */
    public static <T> PageBaseResp<T> buildPageBaseResp(IPage<T> page) {
        PageBaseResp<T> targetPage = new PageBaseResp<>();
        BeanUtils.copyProperties(page, targetPage);
        return targetPage;
    }
}
